package com.htandroid.htandroid.webservice;

import java.util.ArrayList;

import org.xmlpull.v1.XmlSerializer;


import android.util.Xml;

import com.htandroid.htandroid.entity.GcwxList;
import com.htandroid.htandroid.entity.GcwxVouchs;
import com.htandroid.htandroid.entity.GcwxVouchsForeign;
import com.htandroid.htandroid.entity.GcwxVouchsPersons;
import com.htandroid.htandroid.sys.Basenvo;

//生成xml的文本信息
public class BuildGcwxXMLService {

	public String buildXML(String methodName,String namespace,String[] param,String[] val,String param_o1,GcwxList vouch,
						   String param_o2,ArrayList<GcwxVouchs> vouchslist,String param_o3,ArrayList<GcwxVouchsForeign> vouchsforeignlist,String param_o4,ArrayList<GcwxVouchsPersons> vouchspersonslist){
		String xmlstring = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body>";
		//添加方法名
		xmlstring = xmlstring + "<"+methodName+" xmlns=\""+namespace+"\"> \r\n";
		//前参
		for(int i=0;i<param.length;i++){
			xmlstring = xmlstring+"<"+ param[i]+">"+val[i]+"</"+param[i]+"> \r\n";
		}
		if (vouch != null){
			//对象参数
			xmlstring = xmlstring+"<"+ param_o1+">\r\n";
			xmlstring = xmlstring+"<GcwxList xmlns=\"http://entity.test.com\">\r\n";

			xmlstring = xmlstring+"<ID>"+ Basenvo.AdjDigest(vouch.getID())+"</ID>\r\n";
			xmlstring = xmlstring+"<cvouchid>"+Basenvo.AdjDigest(vouch.getCvouchid())+"</cvouchid>\r\n";
			xmlstring = xmlstring+"<ddate>"+Basenvo.AdjDigest(vouch.getDdate())+"</ddate>\r\n";
			xmlstring = xmlstring+"<dqdate>"+Basenvo.AdjDigest(vouch.getDqdate())+"</dqdate>\r\n";
			xmlstring = xmlstring+"<cdepcode>"+Basenvo.AdjDigest(vouch.getCdepcode())+"</cdepcode>\r\n";
			xmlstring = xmlstring+"<cdepname>"+Basenvo.AdjDigest(vouch.getCdepname())+"</cdepname>\r\n";
			xmlstring = xmlstring+"<cwxplcode>"+Basenvo.AdjDigest(vouch.getCwxplcode())+"</cwxplcode>\r\n";
			xmlstring = xmlstring+"<cwxplname>"+Basenvo.AdjDigest(vouch.getCwxplname())+"</cwxplname>\r\n";
			xmlstring = xmlstring+"<cmaker>"+Basenvo.AdjDigest(vouch.getCmaker())+"</cmaker>\r\n";
			xmlstring = xmlstring+"<cbxtext>"+Basenvo.AdjDigest(vouch.getCbxtext())+"</cbxtext>\r\n";
			xmlstring = xmlstring+"<bpressing>"+Basenvo.AdjDigest(vouch.getBpressing())+"</bpressing>\r\n";
			xmlstring = xmlstring+"<cjder>"+Basenvo.AdjDigest(vouch.getCjder())+"</cjder>\r\n";
			xmlstring = xmlstring+"<djddate>"+Basenvo.AdjDigest(vouch.getDjddate())+"</djddate>\r\n";
			xmlstring = xmlstring+"<cwxgcode>"+Basenvo.AdjDigest(vouch.getCwxgcode())+"</cwxgcode>\r\n";
			xmlstring = xmlstring+"<cwxgname>"+Basenvo.AdjDigest(vouch.getCwxgname())+"</cwxgname>\r\n";
			xmlstring = xmlstring+"<cwxpcode>"+Basenvo.AdjDigest(vouch.getCwxpcode())+"</cwxpcode>\r\n";
			xmlstring = xmlstring+"<cwxpname>"+Basenvo.AdjDigest(vouch.getCwxpname())+"</cwxpname>\r\n";
			xmlstring = xmlstring+"<dwcdate>"+Basenvo.AdjDigest(vouch.getDwcdate())+"</dwcdate>\r\n";
			xmlstring = xmlstring+"<dxddate>"+Basenvo.AdjDigest(vouch.getDxddate())+"</dxddate>\r\n";
			xmlstring = xmlstring+"<cxder>"+Basenvo.AdjDigest(vouch.getCxder())+"</cxder>\r\n";
			xmlstring = xmlstring+"<cchecker>"+Basenvo.AdjDigest(vouch.getCchecker())+"</cchecker>\r\n";
			xmlstring = xmlstring+"<dckdate>"+Basenvo.AdjDigest(vouch.getDckdate())+"</dckdate>\r\n";
			xmlstring = xmlstring+"<cresult>"+Basenvo.AdjDigest(vouch.getCresult())+"</cresult>\r\n";
			xmlstring = xmlstring+"<cmemo>"+Basenvo.AdjDigest(vouch.getCmemo())+"</cmemo>\r\n";
			xmlstring = xmlstring+"<cdjcode>"+Basenvo.AdjDigest(vouch.getCdjcode())+"</cdjcode>\r\n";
			xmlstring = xmlstring+"<cdjname>"+Basenvo.AdjDigest(vouch.getCdjname())+"</cdjname>\r\n";
			xmlstring = xmlstring+"<csuspender>"+Basenvo.AdjDigest(vouch.getCsuspender())+"</csuspender>\r\n";
			xmlstring = xmlstring+"<csuspendreason>"+Basenvo.AdjDigest(vouch.getCsuspendreason())+"</csuspendreason>\r\n";
			xmlstring = xmlstring+"<dsuspenddate>"+Basenvo.AdjDigest(vouch.getDsuspenddate())+"</dsuspenddate>\r\n";
			xmlstring = xmlstring+"<ctype>"+Basenvo.AdjDigest(vouch.getCtype())+"</ctype>\r\n";
			xmlstring = xmlstring+"<ctypename>"+Basenvo.AdjDigest(vouch.getCtypename())+"</ctypename>\r\n";
			xmlstring = xmlstring+"<printsend>"+Basenvo.AdjDigest(vouch.getPrintsend())+"</printsend>\r\n";
			xmlstring = xmlstring+"<xzwxnames>"+Basenvo.AdjDigest(vouch.getXzwxnames())+"</xzwxnames>\r\n";
			xmlstring = xmlstring+"<xzwxcodes>"+Basenvo.AdjDigest(vouch.getXzwxcodes())+"</xzwxcodes>\r\n";
			xmlstring = xmlstring+"<eswxdate>"+Basenvo.AdjDigest(vouch.getEswxdate())+"</eswxdate>\r\n";
			xmlstring = xmlstring+"<planvouchid>"+Basenvo.AdjDigest(vouch.getPlanvouchid())+"</planvouchid>\r\n";
			xmlstring = xmlstring+"<plandate>"+Basenvo.AdjDigest(vouch.getPlandate())+"</plandate>\r\n";
			xmlstring = xmlstring+"<checkmemo>"+Basenvo.AdjDigest(vouch.getCheckmemo())+"</checkmemo>\r\n";
			xmlstring = xmlstring+"<isndjz>"+Basenvo.AdjDigest(vouch.getIsndjz())+"</isndjz>\r\n";
			xmlstring = xmlstring+"<cstatus>"+Basenvo.AdjDigest(vouch.getCstatus())+"</cstatus>\r\n";
			xmlstring = xmlstring+"<sucstatus>"+Basenvo.AdjDigest(vouch.getSucstatus())+"</sucstatus>\r\n";
			xmlstring = xmlstring+"</GcwxList>\r\n";
			xmlstring = xmlstring+"</"+ param_o1+">\r\n";
		}
		if (vouchslist != null){
			//对象参数
			xmlstring = xmlstring+"<"+ param_o2+">\r\n";
			for(int i=0;i<vouchslist.size();i++){
				GcwxVouchs vouchs = vouchslist.get(i);
				xmlstring = xmlstring+"<GcwxVouchs xmlns=\"http://entity.test.com\">\r\n";

				xmlstring = xmlstring+"<autoid>"+vouchs.getAutoid()+"</autoid>\r\n";
				xmlstring = xmlstring+"<cvouchid>"+vouchs.getCvouchid()+"</cvouchid>\r\n";
				xmlstring = xmlstring+"<cinvcode>"+vouchs.getCinvcode()+"</cinvcode>\r\n";
				xmlstring = xmlstring+"<iquantity>"+vouchs.getIquantity()+"</iquantity>\r\n";
				xmlstring = xmlstring+"<iprice>"+vouchs.getIprice()+"</iprice>\r\n";
				xmlstring = xmlstring+"<iamount>"+vouchs.getIamount()+"</iamount>\r\n";
				xmlstring = xmlstring+"<cmemo>"+vouchs.getCmemo()+"</cmemo>\r\n";
				xmlstring = xmlstring+"<igetpricenum>"+vouchs.getIgetpricenum()+"</igetpricenum>\r\n";
				xmlstring = xmlstring+"<cobjcode>"+vouchs.getCobjcode()+"</cobjcode>\r\n";
				xmlstring = xmlstring+"<cshdefine1>"+vouchs.getCshdefine1()+"</cshdefine1>\r\n";
				xmlstring = xmlstring+"<cshdefine2>"+vouchs.getCshdefine2()+"</cshdefine2>\r\n";
				xmlstring = xmlstring+"<cshdefine3>"+vouchs.getCshdefine3()+"</cshdefine3>\r\n";
				xmlstring = xmlstring+"<cinvname>"+vouchs.getCinvname()+"</cinvname>\r\n";
				xmlstring = xmlstring+"<cinvstd>"+vouchs.getCinvstd()+"</cinvstd>\r\n";
				xmlstring = xmlstring+"<cinvm_unit>"+vouchs.getCinvm_unit()+"</cinvm_unit>\r\n";
				xmlstring = xmlstring+"</GcwxVouchs>\r\n";
			}
			xmlstring = xmlstring+"</"+ param_o2+">\r\n";
		}
		if (vouchsforeignlist != null){
			//对象参数
			xmlstring = xmlstring+"<"+ param_o3+">\r\n";
			for(int i=0;i<vouchsforeignlist.size();i++){
				GcwxVouchsForeign vouchsforeign = vouchsforeignlist.get(i);
				xmlstring = xmlstring+"<GcwxVouchsForeign xmlns=\"http://entity.test.com\">\r\n";

				xmlstring = xmlstring+"<autoid>"+vouchsforeign.getAutoid()+"</autoid>\r\n";
				xmlstring = xmlstring+"<cvouchid>"+vouchsforeign.getCvouchid()+"</cvouchid>\r\n";
				xmlstring = xmlstring+"<cinvname>"+vouchsforeign.getCinvname()+"</cinvname>\r\n";
				xmlstring = xmlstring+"<cinvstd>"+vouchsforeign.getCinvstd()+"</cinvstd>\r\n";
				xmlstring = xmlstring+"<cinvm_uint>"+vouchsforeign.getCinvm_uint()+"</cinvm_uint>\r\n";
				xmlstring = xmlstring+"<iquantity>"+vouchsforeign.getIquantity()+"</iquantity>\r\n";
				xmlstring = xmlstring+"<iprice>"+vouchsforeign.getIprice()+"</iprice>\r\n";
				xmlstring = xmlstring+"<iamount>"+vouchsforeign.getIamount()+"</iamount>\r\n";
				xmlstring = xmlstring+"<cmemo>"+vouchsforeign.getCmemo()+"</cmemo>\r\n";
				xmlstring = xmlstring+"<igetpricenum>"+vouchsforeign.getIgetpricenum()+"</igetpricenum>\r\n";
				xmlstring = xmlstring+"<cobjcode>"+vouchsforeign.getCobjcode()+"</cobjcode>\r\n";
				xmlstring = xmlstring+"<cshdefine1>"+vouchsforeign.getCshdefine1()+"</cshdefine1>\r\n";
				xmlstring = xmlstring+"<cshdefine2>"+vouchsforeign.getCshdefine2()+"</cshdefine2>\r\n";
				xmlstring = xmlstring+"<cshdefine3>"+vouchsforeign.getCshdefine3()+"</cshdefine3>\r\n";
				xmlstring = xmlstring+"</GcwxVouchsForeign>\r\n";
			}
			xmlstring = xmlstring+"</"+ param_o3+">\r\n";
		}
		if (vouchspersonslist != null){
			//对象参数
			xmlstring = xmlstring+"<"+ param_o4+">\r\n";
			for(int i=0;i<vouchspersonslist.size();i++){
				GcwxVouchsPersons vouchspersons = vouchspersonslist.get(i);
				xmlstring = xmlstring+"<GcwxVouchsPersons xmlns=\"http://entity.test.com\">\r\n";

				xmlstring = xmlstring+"<autoid>"+vouchspersons.getAutoid()+"</autoid>\r\n";
				xmlstring = xmlstring+"<cvouchid>"+vouchspersons.getCvouchid()+"</cvouchid>\r\n";
				xmlstring = xmlstring+"<cwxpcode>"+vouchspersons.getCwxpcode()+"</cwxpcode>\r\n";
				xmlstring = xmlstring+"<cwxptype>"+vouchspersons.getCwxptype()+"</cwxptype>\r\n";
				xmlstring = xmlstring+"<workhours>"+vouchspersons.getWorkhours()+"</workhours>\r\n";
				xmlstring = xmlstring+"<satisfaction>"+vouchspersons.getSatisfaction()+"</satisfaction>\r\n";
				xmlstring = xmlstring+"<cmemo>"+vouchspersons.getCmemo()+"</cmemo>\r\n";
				xmlstring = xmlstring+"<cwxpname>"+vouchspersons.getCwxpname()+"</cwxpname>\r\n";
				xmlstring = xmlstring+"</GcwxVouchsPersons>\r\n";
			}
			xmlstring = xmlstring+"</"+ param_o4+">\r\n";
		}
		xmlstring = xmlstring+"</"+ methodName+">\r\n";
		xmlstring = xmlstring+"</soap:Body></soap:Envelope>";
		return xmlstring;
	}
}
